const lodash = require('lodash');
const stringRandom = require('string-random');

module.exports = {
  /**
     * 生成out_trade_no
     */
  generateOutradeNo(uid) {
    // 后面使用redis
    const date = new Date();
    const d = date.getFullYear() + lodash.padStart((date.getMonth() + 1), 2, '0') + lodash.padStart(date.getDate(), 2, '0') + lodash.padStart(date.getHours(), 2, '0') + lodash.padStart(date.getMinutes(), 2, '0') + lodash.padStart(date.getSeconds(), 2, '0') + lodash.random(100000, 999999);
    return lodash.padEnd(uid, 10, '0') + d;
  },
  randomLenStr(len) {
    return stringRandom(len);
  }
};
